﻿
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_LayoutForEUI.cshtml";
}
<table id="Destroy_Index_grid" class="easyui-datagrid" style="width:100%;" title="销毁档案" data-options="
       rownumbers:true,
       singleSelect:true,
       autoRowHeight:false,
       pagination:true,
       fitColumns:true,
       fit:true,
       striped:true,
       checkOnSelect:false,
       selectOnCheck:false,
       toolbar:'#Destroy_Index_tb',
       collapsible:false,
       pageSize: @SGArchiveSystem7x.Models.CCommonsModels.PageSize,
       pageList:[10,15,20]">
    <thead>
        <tr>
            <th data-options="field:'ck',checkbox:true"></th>
            <th data-options="field:'ar_name',width:120,align:'center'">档案类型</th>
            <th data-options="field:'DH',width:120,align:'center'">档号</th>
            <th data-options="field:'TM',width:120,align:'center'">内容</th>
            <th data-options="field:'ND',width:120,align:'center'">年度</th>
            <th data-options="field:'bgqxname',width:120,align:'center'">保管期限</th>
            <th data-options="field:'desyear',width:120,align:'center'">到期年份</th>
            <th data-options="field:'dep_name',width:120,align:'center'">归档部门</th>
            <th data-options="field:'gdr',width:120,align:'center'">归档人</th>
            <th data-options="field:'mjname',width:120,align:'center'" >密级</th>
        </tr>
    </thead>
</table>
<div id="Destroy_Index_tb" style="padding:5px 10px;">
    <select class="easyui-combobox" labelwidth="60px" style="width:220px" id="Destroy_Index_cmbArchiveType" label="档案类型" labelalign="right" editable="false" panelHeight="auto">
        @{
            var listArchiveType = ViewBag.Items as List<SGArchiveSystem7x.Models.CComboboxModel>;
            foreach (var item in listArchiveType)
            {
                <option value="@item.ID">@item.Text</option>
            }
        }
    </select>
    <select class="easyui-combobox" labelwidth="60px" style="width:220px" id="Destroy_Index_cmDep" label="部门" labelalign="right" editable="false" panelHeight="auto">
        @{
            var listDep = ViewBag.Items2 as List<SGArchiveSystem7x.Models.CComboboxModel>;
            foreach (var item in listDep)
            {
                <option value="@item.ID">@item.Text</option>
            }
        }
    </select>
    <input class="easyui-textbox" label="到期年份:" style="width:220px" labelalign="right" labelwidth="70px"  id="Destroy_Index_txtYear"/>
    <a href="javascript:void(0);" id="Destroy_Index_btnQuery" class="easyui-linkbutton button-blue" onclick="Search()" style="width:110px;height:30px;">查询</a>
    <a href="javascript:void(0);" id="Destroy_Index_btnQC" class="easyui-linkbutton button-blue" onclick="Add_Destory()" style="width:110px;height:30px;">选择建立清册</a>
    <a href="javascript:void(0);" id="Destroy_Index_btnALLQC" class="easyui-linkbutton button-blue" onclick="Add_ALLDestory()" style="width:110px;height:30px;">全部建立清册</a>
</div>
<script>
    $(document).ready(function () {
        $('#Destroy_Index_grid').datagrid({
            url: '/DestroyArchive/Get_ajaxIsDestoryArchive?arid=-1',
            singleSelect: true,
            method: 'post',
            onLoadSuccess: function (data) {
                $('.pagination-page-list').hide();
            }
        });
        InitPagenation();
    });
    function Search() {
        var year = $('#Destroy_Index_txtYear').val();
        var type = $('#Destroy_Index_cmbArchiveType').datebox('getValue');
        var dep = $('#Destroy_Index_cmDep').datebox('getText');
        $('#Destroy_Index_grid').datagrid('options').url = '/DestroyArchive/Get_ajaxIsDestoryArchive?arid=' + type + '&year=' + year + '&dep=' + dep;
        $('#Destroy_Index_grid').datagrid('load');
    }
    function Add_Destory()
    {
        var rows = $('#Destroy_Index_grid').datagrid('getChecked');
        if (rows.length == 0) {
            $.messager.alert('提示！', '请选择要建立清册的档案!', 'info');
            return false;
        }
        else {
            $.messager.confirm('提示', '确定是否建立清册？', function (r) {
                if (r) {
                    $.messager.prompt('提示', '请输入清册名', function (r) {
                        if (r) {
                            var dh = [];
                            for (var i = 0; i < rows.length; i++) {
                                dh.push(rows[i].DH);
                            }
                            $.ajax({
                                url: "/DestroyArchive/Add",
                                dataType: "text",
                                type: "post",
                                data: { 'dh': dh, 'name': r },
                                success: function (data) {
                                    $.messager.alert('提示！', '建立清册成功!', 'info');
                                    $('#Destroy_Index_grid').datagrid('options').url = '/DestroyArchive/Get_ajaxIsDestoryArchive?arid=-1';
                                    $('#Destroy_Index_grid').datagrid('load');
                                }
                            });
                        }
                    });
                }
            })
        }
    }
    function Add_ALLDestory() {
        var rows = $('#Destroy_Index_grid').datagrid('getRows');
        if (rows.length == 0) {
            $.messager.alert('提示！', '无档案进行清册!', 'info');
            return false;
        }
        else {
            $.messager.confirm('提示', '确定是否建立清册？', function (r) {
                if (r) {
                    $.messager.prompt('提示', '请输入清册名', function (r) {
                        if (r) {
                            $.ajax({
                                url: "/DestroyArchive/Add",
                                dataType: "text",
                                type: "post",
                                data: { 'name': r },
                                success: function (data) {
                                    $.messager.alert('提示！', '建立清册成功!', 'info');
                                    $('#Destroy_Index_grid').datagrid('options').url = '/DestroyArchive/Get_ajaxIsDestoryArchive?arid=-1';
                                    $('#Destroy_Index_grid').datagrid('load');
                                }
                            });
                        }
                    });
                }
            })
        }
    }
    ///初始化分页
    function InitPagenation() {
        //设置分页控件
        var p = $('#Destroy_Index_grid').datagrid('getPager');
        $(p).pagination({
            onSelectPage: function (pageNumber, pageSize) {
                QueryPager(pageNumber, pageSize);
            }
        });
    }
    ///分页查询
    function QueryPager(num, size) {
        $('#Destroy_Index_grid').datagrid('options').url = '/DestroyArchive/Get_ajaxIsDestoryArchivePager?num=' + num + '&size=' + size;
        $('#Destroy_Index_grid').datagrid('reload');
        $('#Destroy_Index_grid').datagrid('options').pageNumber = num;
        $('#Destroy_Index_grid').datagrid('options').pageSize = size;
        return;
    }
</script>

